package model.persistence;

import java.util.HashMap;
import java.util.Map;
import model.persistence.dao.PostgresAcessoDAO;
import model.persistence.dao.PostgresCelaDAO;
import model.persistence.dao.PostgresInternoDAO;
import model.persistence.dao.PostgresAtend_SocialDAO;

public class PostgresDAOFactory extends AbstractDAOFactory{
    
    private Map<String, DAO> daos;

    protected PostgresDAOFactory(){
        this.daos = new HashMap<String, DAO>();
        this.daos.put("ACESSO", new PostgresAcessoDAO());
        this.daos.put("CELA", new PostgresCelaDAO());
        this.daos.put("INTERNO", new PostgresInternoDAO());
        this.daos.put("ATEND_SOCIAL", new PostgresAtend_SocialDAO());
        
    }

    @Override
    public DAO createDAO(String entity) throws CloneNotSupportedException{ //ENTITY = NOME DA TABELA
        if(entity == null || entity.equals(""))
            throw new IllegalArgumentException("Nome de tabela inválido");

        if(! this.daos.containsKey(entity))
            throw new IllegalArgumentException("Tabela não existente");

        DAO prototype = this.daos.get(entity);
        return (DAO) prototype.clone();

    }
}
